package org.larkdoc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 跨域请求配置
 * 
 * @author  zhangpeijun
 * @version  [v1.0.1, 2017年3月8日]
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
@Configuration
public class CorsConfig {
    
    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurerAdapter() {
            // 跨域支持
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**");
                //registry.addMapping("/api/**").allowedHeaders("*").allowedMethods("*").allowedOrigins("*");
            }
        };
    }
}
